{include file='comdir/head.html'}
<body>
<div class="content">
    <div class="animated fadeInDown">
        <div class="btn-box">

                当前内容分类：
                    <select class="form-control ctypeid" name="ctypeid"  style="width:200px;height: 30px;vertical-align:middle;display:inline-block;">
                       
                        {foreach from=$contenttypelist item=vo}
                       <option {if $ctypeid==$vo.id} selected{/if} value="{$vo.id}">{$vo.ctypename}</option>
                        {/foreach}
                        
                    </select>
               
            <button class="btn btn-sm btn-success" onclick="add_article();">添加</button>
            <button class="btn btn-sm btn-success" onclick="remove_article();">移除</button>
        </div>
        <div class="searchBox">
            <form class="form-inline">
                <span>
                 标题：<input type="text" class="form-control title " name="title" value="">
                </span>
                <span>
                栏目：
                <select class="form-control colid" name="colid" >
                    <option value="-1">全部</option>
						{$columnselected}
					</select>
                </span>

               
                <span><input type="button" class="form-control btn-blue search-btn" value="搜索"></span>
                <span>
                    排序：
                    <select name="sortvalue" class='form-control sortvalue'>
                    <option {if $sortvalue=='addtime_1'}selected{/if} value="addtime_1">创建时间↓</option>
                    <option {if $sortvalue=='addtime_2'}selected{/if} value="addtime_2">创建时间↑</option>
                    <option {if $sortvalue=='seq_1'}selected{/if} value="seq_1">排序值↓</option>
                    <option {if $sortvalue=='seq_2'}selected{/if} value="seq_2">排序值↑</option>
                </select>
                </span>
            </form>
        </div>

        <div class="table_list_wrap_layer">
            <div class="table-responsive">
                <table class="table table-bordered">
                    <thead>
                        <tr>
                            <th  style="width:200px;">
                            <div class="checkbox checkbox-inline">
                            <span style="width: 50px;display: inline-block;">
                                    <label for="c_checkall">存</label>
                                    <input type="checkbox" id="c_checkall"  disabled name="ccheckall" value="">
                            </span>
                            <span style="width: 50px;display: inline-block;">
                                    <label for="a_checkall">添</label>
                                    <input type="checkbox" id="a_checkall" onchange="checkbox_all(1)" name="acheckall" value="">
                            </span>
                            <span style="width: 50px;display: inline-block;">
                                    <label for="b_checkall">移</label>
                                    <input type="checkbox" id="b_checkall" onchange="checkbox_all(2)" name="bcheckall" value="">
                            </span>
                                </div>
                            </th>
                           
                           
                            <th>ID</th>
                            <th>标题</th>
                            <th>站点</th>
                            <th>栏目</th>
                            <th>排序值</th>
                            <th>新建时间</th>
                        </tr>
                    </thead>
                    <tbody class="listtbody">
                      {foreach from=$list item=vo}
                        <tr>
                        <td>
                                <div class="checkbox checkbox-inline">
                                 <span style="width: 50px;display: inline-block;">
                                    <input type="checkbox" id="c_{$vo.infoid}" disabled class="ccheckone" {if $vo.ischeckobx}checked{/if} name="ccheckone" value="{$vo.infoid}">
                                    <label for="c_{$vo.infoid}"></label>
                                 </span>
                                 <span style="width: 50px;display: inline-block;">
                                     <input type="checkbox" id="a_{$vo.infoid}" class="acheckone" name="acheckone" value="{$vo.infoid}">
                                    <label for="a_{$vo.infoid}"></label>
                                 </span>
                                <span style="width: 50px;display: inline-block;">
                                     <input type="checkbox" id="b_{$vo.infoid}" class="bcheckone"  name="bcheckone" value="{$vo.infoid}">
                                    <label for="b_{$vo.infoid}"></label>
                                 </span>
                                </div>    
                            </td>
                     
                            <td>{$vo.infoid}</td>
                            <td>{$vo.title}</td>
                            <td>{$vo.sitesname}</td>
                            <td>{$vo.columnname}</td>
                            <td>{$vo.seq}</td>
                             <td>{$vo.addtime|date_format:'%Y-%m-%d %H:%M:%S'}</td>
                        </tr>
                        {/foreach}
                    </tbody>
                </table>
            </div>
        </div>
    </div>
    <div class="page-box">
        <div class="page">
        {$pageshow}
        </div>
    </div>
</div>
<div style=""></div>
<script type="text/javascript">
    var _URL='{$_URL}';
    var specialid='{$specialid}';
    {literal}
    $(function(){
        //文章搜索
        $('.search-btn').click(function(){
            ajaxpage(false);
        })
        //排序
        $('.sortvalue').change(function(){
            ajaxpage(false);
        })
        $('.ctypeid').change(function(){
              ajaxpage(false);
        })
    })
    /*全选*/
    function checkbox_all(type){
        if(type==1){//添加
              _checkboxAll.all_move('acheckone','acheckall');
          }else if(type==2){//移除
            _checkboxAll.all_move('bcheckone','bcheckall');
          }
    }
    //添加文章
    function add_article(){
        var valuestr=_checkboxAll.value('acheckone',false,',');
        if(!valuestr){
              layer.msg('未选中文章',{icon: 1}, function(){});
              return false;
        }
        var value=$('.ctypeid').val();
        var url=_URL+"Special/addArticles";
        _ajaxs.post(url,'specialid='+specialid+'&ctypeid='+value+'&infoarr='+valuestr,function(data){
            if(data.status){
                layer.msg(data.msg,{icon: 1}, function(){
                    current_page = $('.current').html();
                    ajaxpage(current_page);
                })
               
            }else{
                layer.msg(data.msg,{icon: 2}, function(){return false;})
            }
        })
    }
    function remove_article(){
        var valuestr=_checkboxAll.value('bcheckone',false,',');
        if(!valuestr){
              layer.msg('未选中文章',{icon: 1}, function(){});
              return false;
        }
        var value=$('.ctypeid').val();
        var url=_URL+"Special/removeArticles";
        _ajaxs.post(url,'specialid='+specialid+'&ctypeid='+value+'&infoarr='+valuestr,function(data){
            if(data.status){
                layer.msg(data.msg,{icon: 1}, function(){
                    current_page = $('.current').html();
                    ajaxpage(current_page);
                })
               
            }else{
                layer.msg(data.msg,{icon: 2}, function(){return false;})
            }
        })
    }
    function ajaxpage(page){
            $('#checkall').prop('checked',false);
            url='';
           // url+=_sousuo.value('.title','title');
            url+=_sousuo.selected('.ctypeid','ctypeid',-1);
            url+=_sousuo.selected('.colid','colid',-1);
            url+=_sousuo.selected('.sortvalue','sortvalue',-1);
            url+='id='+specialid+"&";
            if(page){
                url+="page="+page;
            }else{
                if(url!=''){
                    url=url.substring(0,url.length-1);
                }
            }
            _ajaxs.post(_URL+"Special/addArticles",url,function _return(data){
                $('.listtbody').html('');
                $('.listtbody').html(data.data.list);
                if(data.data.pageshow){
                    $('.page').html(data.data.pageshow);
                }else{
                    $('.page').html('');
                }
            },'json')
        }
    {/literal}
</script>
</body>
</html>